home *** CD-ROM | disk | FTP | other *** search
-
- BASIC Function for Assembler Register Using/Drop
- ================================================
- (directory AsmUsing)
-
- When writing assembler code it is much better to use variable names instead
- of register numbers. This is a great aid to documentation, and gives some
- chance of understanding the code when the inevitable time comes to change
- it.
-
- However, whether variable names or register numbers are used, it is often
- very difficult to keep track of which registers are being used for what. It
- seems to be a fundamental law of computing that, however many registers you
- have, you always seem to need at least one more. This inevitiably leads to
- using a register for several things, which in turn leads to using a register
- for two things at the same time. This confuses the computer, and more so
- the programmer until the error is found! This is a very common cause of
- strange errors in Assembler code which can be very difficult to find.
-
- What is needed is for the assembler to keep track of register usage, but
- unfortunately it does not. However, due to the brilliant integration with
- BASIC, it is fairly easy to add this facility.
-
- Three functions have been written, for inclusion within assembler source:
-
- FNureg, which is inserted into the source code before it is required to use
- a particular register. The register number, the variable name required, and
- a description of its use are passed as parameters. If the register is
- already in use, a warning message is given. The variable, which can be
- either an Integer or a Real variable, can then subsequently be used in the
- source code instead of the register number.
-
- FNdreg, which is used to drop a register when it's use for an item is
- complete. The register number and its variable name are passed as
- parameters, and checked to ensure they are what is being used. If the
- variable name is subsequently used, the assembler will error, as it will be
- set to -1.
-
- FNlreg, which can be used at any time to display a list of registers in use,
- with their variable names and descriptions.
-
- Two PROCedures have been defined also:
-
- PROCireg, which is for initialisation. It is for inclusion in the BASIC
- source, but within the FOR..NEXT loop for the assembly after opt has been
- set to the OPT value. This procedure on the first pass of the assembler
- creates two arrays used to store the variable names and description, and
- uses PROCasmfindvar to assemble a small machine code routine. It then
- initialises the arrays with any common register uses of your choice.
-
- PROCasmfindvar assembles code to find the address and type of any BASIC
- variable, which may be of use for other purposes. If the variable cannot be
- found, then one is created, unless it cannot be a variable name, when an
- error is raised.
-
-
- The sample program DemoUsing includes these facilities as a LIBRARY, and
- produces some warning messages when run.
-
-
-
- Martin Avison